package com.trkj.service.lzs;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.trkj.dao.lzs.SalaryProjectDao;
import com.trkj.pojo.ProjectTemplate;
import com.trkj.pojo.SalaryProject;
import com.trkj.pojo.SocialSecurity;

@Service
public class SalaryProjectService {
	@Autowired
	private SalaryProjectDao salaryProjectDao;
	//查询所有
			public  List<SalaryProject>  SalaryProjectfindAll(){
			   return (List<SalaryProject>) salaryProjectDao.findAll();
			}
		
			//添加
//			public void SalaryProjecttj(Timestamp projectCreatordate,String projectFormula,BigDecimal projectMoney,String projectName, String projectPerson, String projectSource,Timestamp projectUpdatedate) {
//				try {
//					SalaryProject ab= new SalaryProject();
//					ab.setProjectCreatordate(projectCreatordate);
//					ab.setProjectFormula(projectFormula);
//					ab.setProjectMoney(projectMoney);
//					ab.setProjectName(projectName);
//					ab.setProjectPerson(projectPerson);
//					ab.setProjectSource(projectSource);
//					ab.setProjectUpdatedate(projectUpdatedate);
//					salaryProjectDao.save(ab);
//				} catch (Exception e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//				}
//				
//			}
			public void SocialSecuritytj(String projectName ,String projectSource,BigDecimal projectMoney, String projectFormula,Timestamp projectCreatordate,Timestamp projectUpdatedate ) {
				try {
					SalaryProject ab= new SalaryProject();
					ab.setProjectName(projectName);
					ab.setProjectSource(projectSource);
					ab.setProjectMoney(projectMoney);
					ab.setProjectUpdatedate(projectUpdatedate);
					ab.setProjectFormula(projectFormula);
					ab.setProjectCreatordate(projectCreatordate);
					salaryProjectDao.save(ab);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
			//编辑
			   public   void lzs_Edit_a(  Long projectId, String projectName ,String projectSource,BigDecimal projectMoney, String projectFormula,Timestamp projectCreatordate,Timestamp projectUpdatedate) {
				   SalaryProject edit =salaryProjectDao.findOne(projectId);
				   edit.setProjectName(projectName);
				   edit.setProjectSource(projectSource);
				   edit.setProjectMoney(projectMoney);
				   edit.setProjectUpdatedate(projectUpdatedate);
				   edit.setProjectFormula(projectFormula);
				   edit.setProjectCreatordate(projectCreatordate);
				   salaryProjectDao.save(edit);
		     }
			     public SalaryProject chun_a(Long projectId) {
			    	 return salaryProjectDao.findOne(projectId);
			 		
			     } 
			   //模糊查询
			  		//根据姓名查找
			  		public  List<SalaryProject> queryByName (String  text){
			  			return salaryProjectDao.queryByName("%" + text + "%");
			  		}
			  	//删除
					 public boolean dltRaw(Long projectId) {
					 		if(salaryProjectDao.exists(projectId)){
					 			salaryProjectDao.delete(projectId);
					 			 return true;
					 		}
					 		return false;		
				
					 }
			     
}
